﻿using System;
using System.Linq.Expressions;
using Fabrication.Extensions;

namespace Fabrication
{
    public static class ChildPropertySelectorExtensions
    {
        public static IBuilderOptions<TParent> To<TParent, TChild, TParam>(this ChildPropertySelector<TParent, TChild, TParam> childPropertySelector, Expression<Func<TParent, TParam>> member)
        {
            var propertyName = member.GetPropertyName();

            var builderOptions = childPropertySelector.ChildBuilderOptions.BuilderOptions;
            builderOptions.AddChildLink(typeof(TParent), typeof(TChild), typeof(TParam), propertyName, childPropertySelector.PropertyName);
            return builderOptions;
        }
    }
}